home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / oper_sys / emerald / emrldsys.lha / Kernel / Em / mainLoop.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-08-17  |  1.7 KB  |  61 lines

  1.  
  2. /* File: ~eden/Kernel/Em/mainLoop.c     Origin: 1985-07-09 eric */
  3.  
  4. /*  C O P Y R I G H T   N O T I C E :                                     */
  5. /* Copyright 1986 Eric Jul and Norm Hutchinson.     May not be used for any  */
  6. /* purpose without written permission from the authors.              */
  7.  
  8. /* Revision 2.0 started 1985-09-13 */
  9. /* Revision 3.0 started 1986-02-20 */
  10. /* Revision 3.1 started 1986-03-01 */
  11.  
  12. /* This is the main loop for handling the kernel task queue.
  13.  */
  14.  
  15. #include "Kernel/h/stdTypes.h"
  16. #include "Kernel/h/kmdTypes.h"
  17. #include "Kernel/h/kEvents.h"
  18. #include "Kernel/h/emTypes.h"
  19.  
  20. #ifndef NULL
  21. #define NULL 0
  22. #endif  NULL
  23. /*
  24.  * MainLoop()
  25.  *
  26.  * The main loop.  Checks TaskQ, and if there are any tasks waiting to
  27.  * run, calls them.  Does HoldSigs() and ReleaseSigs() to protect the queue.
  28.  */
  29. extern void edenPause();
  30. extern void ErrMsg();
  31.  
  32. /**********************************************************************/
  33.  
  34. void MainLoop()
  35. {
  36.     struct TaskQueue *event;
  37.     int             (*handler)();
  38.     char            *argument;
  39. doMore:
  40. #ifndef xkernel
  41.     HoldSigs();
  42. #endif
  43.     event = TaskDequeue(&TaskQ);
  44.     if (event != (struct TaskQueue *) NULL) {
  45.         handler = event->handler;
  46.         argument = event->arg;
  47.         TaskEnqueue(&FreeQ, event);
  48. #ifndef xkernel
  49.         ReleaseSigs();
  50. #endif
  51.         DebugMsg(7, "Calling handler 0x%06x with 0x%06x\n", handler, argument);
  52.         (void) ((*handler)(argument));
  53.         DebugMsg(7, "Handler 0x%06x returned\n", handler);
  54.         goto doMore;
  55.     }
  56. }
  57.  
  58. /*  C O P Y R I G H T   N O T I C E :                                     */
  59. /* Copyright 1986 Eric Jul and Norm Hutchinson.     May not be used for any  */
  60. /* purpose without written permission from the authors.              */
  61.